#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float32.hpp"
#include "geometry_msgs/msg/twist.hpp"

float a=0.0;

float v=0.8,w=0.0,R=1.0;

class NodeTe : public rclcpp::Node
{
private:
    // 声名定时器指针
    rclcpp::TimerBase::SharedPtr timer_;
    // 声明话题发布者指针
    rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr fabuzhe;
    // 声明话题发布者指针
    rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr turtle_pub;
    //
    void timer_callback()
    {
        auto msg=geometry_msgs::msg::Twist();//创建参数msg，类型twist
        msg.linear.x=0.8;//给里面的x轴线速度赋值0.8m/s
        msg.angular.z=0.0;//给里面的z轴角速度赋值0.0rad/s
        turtle_pub->publish(msg);//赋值完成，发布信息
    }

public:
    NodeTe(std::string name) : Node(name)
    {
        RCLCPP_INFO(this->get_logger(), "%s节点已经启动.", name.c_str());
        // 创建发布者
        fabuzhe= this->create_publisher<std_msgs::msg::Float32>("ikun_receive", 10);
        // 创建定时器，250ms为周期，定时发布
        timer_= this->create_wall_timer(std::chrono::milliseconds(250), std::bind(&NodeTe::timer_callback, this));
        //创建乌龟发布者
        turtle_pub=this->create_publisher<geometry_msgs::msg::Twist>("turtle1/cmd_vel", 10);
    }

};


int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    /*创建对应节点的共享指针对象*/
    auto node = std::make_shared<NodeTe>("node_te");
    /* 运行节点，并检测退出信号*/
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}